<template>
	<view class="mainpadding">
		<view class="shangbj flexbetween" v-for="(item,index) in list.data" :key="item.id" @click="jumpDetail(item.id,item.user.id);item.view_num =Number(item.view_num)+1">
			<image class="suzicon" src="../static/image/sysem/one.png" mode="" v-if="index==0"></image>
			<image class="suzicon" src="../static/image/sysem/two.png" mode="" v-else-if="index==1"></image>
			<image class="suzicon" src="../static/image/sysem/three.png" mode="" v-else-if="index==2"></image>
			<view class="suzicon" v-else></view>
			<view class="flexleft" style="width: 90%;">
				<image class="shilitu margin_right3" :src="item.image_text" mode=""></image>
				<view class="">
					<view class="ershil xiaobai yhxk">{{item.des}}</view>
					<view class="ershil xiaohui margin_top">{{item.view_num}}</view>
					<view class="flexleft margin_top">
						<image class="touxiang margin_right1" :src="item.user.avatar_text" mode=""></image>
						<view class="strongtext xiaohui">{{item.user.nickname}}</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")

	export default {
		data() {
			return {
				page: 1,
				limit: 12,
				list: {
					data: []
				},
			}
		},
		onLoad() {
			this.init()
		},
		methods: {
			jumpDetail(id, listuser_id) {
				uni.navigateTo({
					url: "/pages_homepage/shipinxq?id=" + id + "&listuser_id=" + listuser_id
				})
				this.addviewnum(id)
			},
			addviewnum(id) {
				httpRequest.request('/api/videocl/addViewNum', 'GET', {
					id
				}).then(res => {})
			},
			init(isPage, page) {
				let _this = this
				let data = {
					page: page || 1,
					limit: 12,
					view_sort:1
				}
				httpRequest.request('/api/videocl/videoIndex', 'GET', data).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			jumper(url, val) {
				uni.navigateTo({
					url: url + val
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.touxiang {
		width: 40rpx;
		height: 40rpx;
		border-radius: 50%;
	}

	.shilitu {
		min-width: 243rpx;
		width: 243rpx;
		height: 176rpx;
		border-radius: 12rpx;
	}

	.suzicon {
		width: 50.08rpx;
		height: 50.08rpx;
	}

	.shangbj {
		margin-top: 30rpx;
	}

	.shangbj:first-child {
		margin-top: 0rpx;
	}
</style>